package com.parse.ip.parseip.service.impl;

import com.parse.ip.parseip.entity.Telephone;
import com.parse.ip.parseip.mapper.ParseTelephoneMapper;
import com.parse.ip.parseip.service.ParseTelephone;
import com.parse.ip.parseip.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class ParseTelephoneImpl implements ParseTelephone {

    @Autowired
    private ParseTelephoneMapper parseTelephoneMapper;

    @Autowired
    private RedisUtil redisUtil;
    @Override
    public void save(Telephone telephone) {
        telephone.setId(UUID.randomUUID().toString().replace("-",""));
        parseTelephoneMapper.save(telephone);
        redisUtil.set(telephone.getTelephone(),telephone,1000*60*24*7);
    }
}
